﻿using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;


namespace WebApplication2
{
    public partial class show : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) 
            {
                bind();
                
            }
        }
        public void bind() 
        {
            
            this.GridView1.DataSource = studentBLL.getALL();
            this.GridView1.DataBind();
        }

        protected void Button3_Command(object sender, CommandEventArgs e)
        {
            var id = Convert.ToInt32(e.CommandArgument.ToString());
            var num = studentBLL.deleteBYID(id);
            if (num > 0)
            {
                Response.Write("<script>alert('删除成功')</script>");
                bind();
            }
            else
            {
                Response.Write("<script>alert('删除失败')</script>");
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("ADD.aspx");
        }

        protected void Button4_Command(object sender, CommandEventArgs e)
        {
            var sno = e.CommandArgument.ToString();
            Response.Redirect("updatestudent.aspx?sno=" + sno);
            

        }
    }
}